﻿@model IEnumerable<K3TOOLS.Models.TableInfo>
@{
    Layout = null;
}

<script src="~/lib/jquery/dist/jquery.js"></script>

<table class="table table-bordered table-hover table-striped" style="word-break:break-all;word-wrap:break-all;">
    <tr class="info">
        <th>表名列表</th>
        <th>注释</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td style="max-width:500px;">
                @if (!string.IsNullOrEmpty(item.TableList) && item.TableList.Trim().Length > 0)
                {
                    item.TableList = item.TableList.Substring(0, item.TableList.Length - 1);
                    List<string> tbList = item.TableList.Split(",").ToList();
                    foreach(var tb in tbList)
                    {
                        <a class="btn btn-info TableDetail" data-toggle="modal" data-target="#myModal">@tb</a>
                    }
                }
                else
                {
                    @item.TableList
                }
            </td>

            <td>@item.TableDescription</td>
        </tr>

    }

</table>
<script>
    $(".TableDetail").on("click", function () {
        GetTableDetail(this);
    })

    function GetTableDetail(obj) {
        var TableName = $(obj).text();
        $("#myModalLabel").html(TableName + "表结构详情")

        var PostUrl = "/home/TableDetail";

        $.post(PostUrl, { TableName: TableName }, function (data) {
            $(".modal-body").html(data);
        });

        

    };
</script>
